var o, e = require,
    t = module,
    n = exports,
    i = this && this.__extends || (o = function(t, e) {
        return (o = Object.setPrototypeOf || {
                __proto__: []
            }
            instanceof Array && function(t, e) {
                t.__proto__ = e;
            } || function(t, e) {
                for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
            })(t, e);
    }, function(t, e) {
        function n() {
            this.constructor = t;
        }
        o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype,
            new n());
    }),
    a = this && this.__decorate || function(t, e, n, o) {
        var a, i = arguments.length,
            c = i < 3 ? e : null === o ? o = Object.getOwnPropertyDescriptor(e, n) : o;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) c = Reflect.decorate(t, e, n, o);
        else
            for (var r = t.length - 1; 0 <= r; r--)(a = t[r]) && (c = (i < 3 ? a(c) : 3 < i ? a(e, n, c) : a(e, n)) || c);
        return 3 < i && c && Object.defineProperty(e, n, c), c;
    };

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("BattleItemView"),
    s = e("ActionView"),
    c = e("Global"),
    l = e("GameManager"),
    d = e("PrefabView"),
    u = e("AudioManager"),
    p = e("GameConfig"),
    h = e("GameData"),
    f = e("WebManager"),
    g = cc._decorator,
    m = g.ccclass,
    y = g.property,
    v = function(e) {
        function t() {
            var t = null !== e && e.apply(this, arguments) || this;
            return t.leftLayout = null, t.rightLayout = null, t.timeLabel = null, t.item = null,
                t.items = [], t;
        }
        return i(t, e), t.prototype.start = function() {},
            t.prototype.init = function(e, n) {
                var o = this;
                void 0 === e && (e = 5), f.default.getInstance().getRobotList({
                    grade: c.G.getRank(h.GD.level).r,
                    weapon: h.GD.topRank,
                    skin: h.GD.personIdx,
                    streak: c.G.wincount,
                    robotNum: e,
                    success: function(t) {
                        console.error(t);
                        0 == t.data.code ? (t.data.data instanceof Array && t.data.data.forEach(function(t, e) {
                            e = l.default.getInstance().model.ais[e];
                            e.icon = t.icon, e.nickname = t.nickname, isNaN(t.checkTime) || (e.think = t.checkTime / 1e3),
                                isNaN(t.weapon) || (e.gunIdx = t.weapon), isNaN(t.skin) || (e.personIdx = t.skin);
                        }), o.doEffect(), o.loadComplete(n)) : f.default.getInstance().getSomeRobots({
                            limit: e,
                            success: function(t) {
                                cc.log("getSomeRobots", t), t.data.data instanceof Array && t.data.data.forEach(function(t, e) {
                                    e = l.default.getInstance().model.ais[e];
                                    e.icon = t.icon, e.nickname = t.nickname;
                                }), o.doEffect(), o.loadComplete(n);
                            },
                            fail: function(t) {
                                console.error(t);
                            }
                        });
                    },
                    fail: function(t) {
                        console.error(t);
                    }
                });
            }, t.prototype.doEffect = function() {
                var t, a = this,
                    i = c.G.getRank(h.GD.level).r,
                    e = cc.instantiate(this.item.node),
                    n = e.getComponent(r.default);
                n && ((t = e.getComponent(s.default)) && (t.vec = cc.v2(-800, 0), t.delay = .1),
                    e.active = !0, e.x = 3 * -this.item.node.width / 2 + .5 * e.width, e.parent = this.rightLayout,
                    n.personView.node.scaleX = -1, n.init(l.default.getInstance().model.curPlayer, i),
                    this.items.push(n));
                var d = 1,
                    u = 0;
                l.default.getInstance().model.ais.forEach(function(t) {
                    var e, n, o;
                    t.group == l.default.getInstance().model.curPlayer.group ? ((o = (n = cc.instantiate(a.item.node)).getComponent(r.default)) && ((e = n.getComponent(s.default)) && (e.vec = cc.v2(-800, 0),
                            e.delay = .1 * (d + 1)), n.active = !0, n.x = 3 * -a.item.node.width / 2 + n.width * (d + .5),
                        n.parent = a.rightLayout, o.personView.node.scaleX = -1, o.init(t, Math.max(p.GC.battleRankLimit, GA.rand(i - 1, Math.min(i + 1, c.G.levelList.length - 1)))),
                        a.items.push(o)), d++) : ((o = (n = cc.instantiate(a.item.node)).getComponent(r.default)) && ((e = n.getComponent(s.default)) && (e.vec = cc.v2(800, 0),
                            e.delay = .1 * (u + 1)), n.active = !0, n.x = 3 * a.item.node.width / 2 - n.width * (u + .5),
                        n.parent = a.leftLayout, o.init(t, Math.max(p.GC.battleRankLimit, GA.rand(i - 1, Math.min(i + 1, c.G.levelList.length - 1)))),
                        a.items.push(o)), u++);
                });
            }, t.prototype.loadComplete = function(t) {
                var e = this;

                var n = 3;
                this.timeLabel.string = n.toString(), this.schedule(function() {

                    console.error(11);
                    u.default.getInstance().playAudio("倒计时321"), n--, e.timeLabel.string = n.toString(),
                        0 == n && (t && t(), e.hidePnl(), l.default.getInstance().doStart());
                }, 1, 2, 0);
            }, a([y(cc.Node)], t.prototype, "leftLayout", void 0), a([y(cc.Node)], t.prototype, "rightLayout", void 0),
            a([y(cc.Label)], t.prototype, "timeLabel", void 0), a([y(r.default)], t.prototype, "item", void 0),
            a([m], t);
    }(d.default);

n.default = v;